﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using Manas.Silverlight.DynamicDeepZoom.TileSources;

namespace Manas.Silverlight.DynamicDeepZoom
{
    public class DeepZoomViewModel : INotifyPropertyChanged
    {
        readonly Type TileSourceType = typeof(DynamicTileSource);

        public DeepZoomViewModel()
        {
            this.TileSource = Activator.CreateInstance(TileSourceType, Configuration.Default) as MultiScaleTileSource;
        }

        #region Tile Source

        private MultiScaleTileSource tileSource;
        public MultiScaleTileSource TileSource
        {
            get { return tileSource; }
            set
            {
                if (tileSource != value)
                {
                    tileSource = value;
                    RaisePropertyChanged("TileSource");
                }
            }
        }

        #endregion

        #region INotifyPropertyChanged Members

        protected void RaisePropertyChanged(string propname)
        {
            var handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propname));
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }
}
